//
//  FLMMessageTableViewCell.m
//  FLMSuperS
//
//  Created by chenshan on 2016/10/9.
//  Copyright © 2016年 FaLaoMiaoNetworkTechnologyCo. All rights reserved.
//

#import "FLMMessageTableViewCell.h"

@interface FLMMessageTableViewCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *infoLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UIView *bottomLine;
@property (nonatomic, strong) UIImageView  *focusImageView;

@end

@implementation FLMMessageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if(self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self commonInit];
    }
    return self;
}

- (void)commonInit {
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    [self.contentView addSubview:(_bottomLine = [[UIView alloc] init])];
    _bottomLine.backgroundColor = [UIColor lightGrayColor];
    [_bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.bottom.mas_equalTo(1);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
    }];

    
    [self.contentView addSubview:(_focusImageView = [[UIImageView alloc] init])];
    _focusImageView.image = [UIImage imageNamed:@"2"];
    
    [self.contentView addSubview:(_titleLabel = [[UILabel alloc] init])];
    _titleLabel.font = [UIFont systemFontOfSize:15.0];
    _titleLabel.textColor = [UIColor blackColor];
    
    [self.contentView addSubview:(_infoLabel = [[UILabel alloc] init])];
    _infoLabel.font = [UIFont systemFontOfSize:12.0];
    _infoLabel.textColor = [UIColor lightGrayColor];
    
    [self.contentView addSubview:(_timeLabel = [[UILabel alloc] init])];
    _timeLabel.textAlignment = NSTextAlignmentRight;
    _timeLabel.font = [UIFont systemFontOfSize:12.0];
    _timeLabel.textColor = [UIColor lightGrayColor];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    _focusImageView.left = 15;
    _focusImageView.top = 5;
    _focusImageView.height = self.height - 10;
    _focusImageView.width = _focusImageView.height;
    
    _titleLabel.left = _focusImageView.right + 15;
    _titleLabel.top = 20;
    _titleLabel.height = 18;
    _titleLabel.width = self.width  - _focusImageView.right  - 15;
    
    _infoLabel.left = _titleLabel.left;
    _infoLabel.top = _titleLabel.bottom + 10;
    _infoLabel.height = 18;
    _infoLabel.width = _titleLabel.width;
    
    _timeLabel.left = self.width - 50 - 20;
    _timeLabel.height = 18;
    _timeLabel.width = 50;
    _timeLabel.centerY = self.height/2;
}

- (void)setModel:(NSDictionary *)model {
    _titleLabel.text = model[@"title"];
    _timeLabel.text = model[@"time"];
    _infoLabel.text = model[@"info"];
}

@end
